Due to bug 17259 (which is fixed in a better way in Id44d566a),
imagelinks only records the redirect and not the actual image used when
an image redirect is referenced. This causes various problems, such as
cascading protection not working through image redirects.
It makes more sense for imagelinks to work like tempaltelinks, recording
both so that things like cascading protection don't have to care about
image redirects explicitly.
Comparing imagelinks to templatelinks also reveals a few places
(WikiPage::doDeleteUpdates, WikiPage::doCascadeProtectionUpdates) that
should be triggering a LinksUpdate if the image links changed.
Bug: 23002
Bug: 23542
Bug: 26503
Change-Id: I64fe7d25646cae2c8213211893c6f821f3504dbf
messages have been updated and marked for review at translatewiki.net.
* (bug 14323) Redirect pages, when viewed with redirect=no, no longer hide the
remaining page content.
messages have been updated and marked for review at translatewiki.net.
* (bug 14323) Redirect pages, when viewed with redirect=no, no longer hide the
remaining page content.
+* (bug 23542) imagelinks now stores both the redirect and target (as
+ templatelinks does).
=== Web API changes in 1.23 ===
* (bug 54884) action=parse&prop=categories now indicates hidden and missing
=== Web API changes in 1.23 ===
* (bug 54884) action=parse&prop=categories now indicates hidden and missing
// Reparse any pages transcluding this page
LinksUpdate::queueRecursiveJobsForTable( $this->mTitle, 'templatelinks' );
// Reparse any pages transcluding this page
LinksUpdate::queueRecursiveJobsForTable( $this->mTitle, 'templatelinks' );
+ // Reparse any pages including this image
+ if ( $this->mTitle->getNamespace() == NS_FILE ) {
+ LinksUpdate::queueRecursiveJobsForTable( $this->mTitle, 'imagelinks' );
+ }
+
// Clear caches
WikiPage::onArticleDelete( $this->mTitle );
// Clear caches
WikiPage::onArticleDelete( $this->mTitle );
- // templatelinks table may have become out of sync,
+ // templatelinks or imagelinks tables may have become out of sync,
// especially if using variable-based transclusions.
// For paranoia, check if things have changed and if
// so apply updates to the database. This will ensure
// that cascaded protections apply as soon as the changes
// are visible.
// especially if using variable-based transclusions.
// For paranoia, check if things have changed and if
// so apply updates to the database. This will ensure
// that cascaded protections apply as soon as the changes
// are visible.
- // Get templates from templatelinks
+ // Get templates from templatelinks and images from imagelinks
- $tlTemplates = array();
$dbr = wfGetDB( DB_SLAVE );
$res = $dbr->select( array( 'templatelinks' ),
$dbr = wfGetDB( DB_SLAVE );
$res = $dbr->select( array( 'templatelinks' ),
);
foreach ( $res as $row ) {
);
foreach ( $res as $row ) {
- $tlTemplates["{$row->tl_namespace}:{$row->tl_title}"] = true;
+ $dbLinks["{$row->tl_namespace}:{$row->tl_title}"] = true;
+ }
+
+ $dbr = wfGetDB( DB_SLAVE );
+ $res = $dbr->select( array( 'imagelinks' ),
+ array( 'il_to' ),
+ array( 'il_from' => $id ),
+ __METHOD__
+ );
+
+ foreach ( $res as $row ) {
+ $dbLinks[NS_FILE . ":{$row->il_to}"] = true;
- // Get templates from parser output.
- $poTemplates = array();
+ // Get templates and images from parser output.
+ $poLinks = array();
foreach ( $parserOutput->getTemplates() as $ns => $templates ) {
foreach ( $templates as $dbk => $id ) {
foreach ( $parserOutput->getTemplates() as $ns => $templates ) {
foreach ( $templates as $dbk => $id ) {
- $poTemplates["$ns:$dbk"] = true;
+ $poLinks["$ns:$dbk"] = true;
+ foreach ( $parserOutput->getImages() as $dbk => $id ) {
+ $poLinks[NS_FILE . ":$dbk"] = true;
+ }
- $templates_diff = array_diff_key( $poTemplates, $tlTemplates );
+ $links_diff = array_diff_key( $poLinks, $dbLinks );
- if ( count( $templates_diff ) > 0 ) {
+ if ( count( $links_diff ) > 0 ) {
// Whee, link updates time.
// Note: we are only interested in links here. We don't need to get other DataUpdate items from the parser output.
$u = new LinksUpdate( $this->mTitle, $parserOutput, false );
// Whee, link updates time.
// Note: we are only interested in links here. We don't need to get other DataUpdate items from the parser output.
$u = new LinksUpdate( $this->mTitle, $parserOutput, false );
/**
* Queue recursive jobs for this page
*
/**
* Queue recursive jobs for this page
*
- * Which means do LinksUpdate on all templates
- * that include the current page, using the job queue.
+ * Which means do LinksUpdate on all pages that include the current page,
+ * using the job queue.
*/
function queueRecursiveJobs() {
self::queueRecursiveJobsForTable( $this->mTitle, 'templatelinks' );
*/
function queueRecursiveJobs() {
self::queueRecursiveJobsForTable( $this->mTitle, 'templatelinks' );
+ if ( $this->mTitle->getNamespace() == NS_FILE ) {
+ // Process imagelinks in case the title is or was a redirect
+ self::queueRecursiveJobsForTable( $this->mTitle, 'imagelinks' );
+ }
LinksUpdate::queueRecursiveJobsForTable( $this->getTitle(), 'imagelinks' );
}
LinksUpdate::queueRecursiveJobsForTable( $this->getTitle(), 'imagelinks' );
}
- # Invalidate cache for all pages that redirects on this page
- $redirs = $this->getTitle()->getRedirectsHere();
-
- foreach ( $redirs as $redir ) {
- if ( !$reupload && $redir->getNamespace() === NS_FILE ) {
- LinksUpdate::queueRecursiveJobsForTable( $redir, 'imagelinks' );
- }
- $update = new HTMLCacheUpdate( $redir, 'imagelinks' );
- $update->doUpdate();
- }
-
wfProfileOut( __METHOD__ );
return true;
wfProfileOut( __METHOD__ );
return true;
if ( $file && !$title->equals( $file->getTitle() ) ) {
# Update fetched file title
$title = $file->getTitle();
if ( $file && !$title->equals( $file->getTitle() ) ) {
# Update fetched file title
$title = $file->getTitle();
- if ( is_null( $file->getRedirectedTitle() ) ) {
- # This file was not a redirect, but the title does not match.
- # Register under the new name because otherwise the link will
- # get lost.
- $this->mOutput->addImage( $title->getDBkey(), $time, $sha1 );
- }
+ $this->mOutput->addImage( $title->getDBkey(), $time, $sha1 );
}
return array( $file, $title );
}
}
return array( $file, $title );
}